Contentful API
JS library
contentful.js
contentful-management.js
github
5種類ある ref
Content Delivery API
Content Management API
コンテンツの取得や作成、その他の設定を行うためのAPI
docs
Content Preview API
Images API
Contentfulにアップロードしたイメージの取得用
画像のサイズ変更やWebP等への変換に対応している
GraphQL Content API
GraphQL
#WIP
Domain Model
https://www.contentful.com/developers/docs/concepts/domain-model/
User
Contentfulのaccountを持っている人
Organizations
Spaces
Organizationsの子
HP用、サービス用みたいなprojectごとのやつかなmrsekut.icon
Environments
Content
EntityのCollection
Content Model
Media
Locales
用語がわからん
Content
EntityのCollection
ContentfulのContent Model
Content TypeのCollection
Media
AsssetのCollection
Locales
ContentfulのEntry
Content Typeが型なら、Entryはその実体
ContentfulのAsset
画像などのbinary files
https://www.contentful.com/developers/docs/references/content-delivery-api/#/reference/assets
ContentfulのContent Type
Contentの雛形
型定義みたいなやつ
例えば、記事の型とか、キーワードの型とか
Content Typeに含まれる各項目のことをFieldと言う(?)
ContentType
https://www.contentful.com/developers/docs/concepts/data-model/
code:ts
export interface ContentType {
sys: Sys;
name: string;
description: string;
displayField: string;
fields: Array<Field>;
toPlainObject(): object;
}
Entry
code:ts
export interface Entry<T> {
sys: Sys;
fields: T;
metadata: Metadata;
toPlainObject(): object;
update(): Promise<Entry<T>>;
}
Sys
基本情報的な
code:ts
export interface Sys {
type: string;
id: string;
createdAt: string;
updatedAt: string;
locale: string;
revision?: number;
space?: {
sys: SpaceLink;
};
environment?: {
sys: EnvironmentLink;
};
contentType: {
sys: ContentTypeLink;
};
}
Field
ContentTypeに含まれる1つ1つのfield
1つのformのようなものをイメージするといい
code:ts
export interface Field {
disabled: boolean;
id: string;
linkType?: string;
localized: boolean;
name: string;
omitted: boolean;
required: boolean;
type: FieldType;
validations: FieldValidation[];
items?: FieldItem;
}
#やりたいこと
fieldsの型を自動生成してほしい
https://github.com/intercom/contentful-typescript-codegen
これか?
エンドポイントを指定すると、Draftなものもクライアントに表示することができるが、その際にrequiredを全て埋めているかを判定してfilterしたい
https://www.contentful.com/developers/docs/references/content-management-api/#/reference/content-types/content-type
validationで指定するのかな?
そのModelがDraftなのかPublishedなのかを判定する
https://www.contentful.com/developers/docs/tutorials/general/determine-entry-asset-state/
https://www.contentfulcommunity.com/t/published-or-draft/632/5
Preview APIでは無理らしい
API
https://www.contentful.com/developers/docs/references/
https://zenn.dev/panyoriokome/scraps/078396c329f25c